package cooperated

import (
	"gddgame.cc/galaxy/common/namespaces/cooperate"
	"gddgame.cc/galaxy/common/namespaces/cooperate/structure"
)

func (logic *TypeMap) SpeedTeleport(info InfoContainer, speedTeleport *SpeedTeleportLogic) {
	target := info.GetTarget()
	switch target.DataType {
	case UnitType:
	default:
		return
	}
	instance := logic.GetDetailCache(logic, target)
	if instance == nil {
		return
	}
	selfIdentity := instance.ToInt(Identity)
	visible := TargetVisible(instance.ToByte(Visible))
	position := instance.ToBytes(Position)
	// 更新状态和忽略
	operateData := &cooperate.UpdateOperateData{
		Data: *structure.NewBaseDataFrom(target),
		Operates: []cooperate.UpdateOperateContent{{
			Operate: cooperate.ChangePosition,
			Value:   speedTeleport.Target,
		}},
	}
	logic.scheduleBatchUpdateOperate2(info, operateData, 0)
	logic.setBlock(instance, position, speedTeleport.Target, nil, info.GetTime(), info.GetTime(), selfIdentity, visible)
	// 发送传送事件
	extend := cooperate.NewModeExtend([]interface{}{speedTeleport.Target}, logic.GetMapNoId(), nil, position)

	logic.Mode(logic, info.GetFrom(), target, speedTeleport.Arrive, info.GetTime(), extend)
}
